_Pragma("once");

#include <iostream>
#include <cstdint>


using LoopSize_t = std::uint32_t;

constexpr int MAX_TRY_COUNT = 3;



constexpr char GENERAL_CONTROL_FILE[] = "/dev/other_gpio0";

#define CARD_MAJIC  'c'
#define IOREQ_BUZZER_ON			_IO (CARD_MAJIC, 0xa4)
#define IOREQ_BUZZER_OFF		_IO (CARD_MAJIC, 0xa5)


#define IOREQ_CARDA_1_EN		_IO (CARD_MAJIC, 0xa0)
#define IOREQ_CARDA_1_OFF		_IO (CARD_MAJIC, 0xa1)
#define IOREQ_CARDA_2_EN		_IO (CARD_MAJIC, 0xa2)
#define IOREQ_CARDA_2_OFF		_IO (CARD_MAJIC, 0xa3)



#define DEVICE_RETRY

// for(int i = COUNT, (ACTION); 0 <= i && !(EXPRESSION) ; --i, (ACTION));
#ifdef DEVICE_RETRY
#define REPEAT_COUNT(COUNT, EXPRESSION)   for(int i = (COUNT); 0 <= i && !(EXPRESSION) ; --i)
#define REPEAT_ACTION_COUNT(COUNT, ACTION, EXPRESSION)   for(int i = ((ACTION), COUNT); 0 < i && !(EXPRESSION) ; --i, (ACTION))
#else
#define REPEAT_COUNT(COUNT, EXPRESSION)  (EXPRESSION);
#define REPEAT_ACTION_COUNT(COUNT, ACTION, EXPRESSION)     (EXPRESSION);
#endif


#define REPEAT(EXPRESSION)   REPEAT_COUNT(MAX_TRY_COUNT, EXPRESSION)
#define REPEAT_ACTION(ACTION, EXPRESSION)        REPEAT_ACTION_COUNT(MAX_TRY_COUNT, ACTION, EXPRESSION)








